#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=3e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn][10];
LL ans1=1,ans2=1;
LL vis[1<<9];
bool check(LL x,LL n,LL m){
     memset(vis,0,sizeof(vis));
     for(LL i=1;i<=n;i++){
         LL val=0;
         for(LL j=1;j<=m;j++){
            if(a[i][j]>=x){
                val|=(1<<(j-1));
            }
         }
         vis[val]=i;
     }
     for(LL i=0;i<(1<<m);i++){
         if(!vis[i]) continue;
         for(LL j=0;j<(1<<m);j++){
            if(!vis[j]) continue;
            if((i|j)==(1<<m)-1){
                ans1=vis[i];
                ans2=vis[j];
                return true;
            }
         }
     }
     return false;
}
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   LL n,m;cin>>n>>m;
   for(LL i=1;i<=n;i++){
       for(LL j=1;j<=m;j++){
           cin>>a[i][j];
       }
   }
   LL l=0;LL r=1e9+1;
   while(l<r){
      LL mid=(l+r+1)>>1;
      if(check(mid,n,m)) l=mid;
      else r=mid-1;
   }
   cout<<ans1<<" "<<ans2<<"\n";
   return 0;
}
